// 存储的方法
export const setItem = (key, data) => {
    if (typeof data === 'object') {
      localStorage.setItem(key, JSON.stringify(data))
    } else {
      localStorage.setItem(key, data)
    }
  }
  
  // 读取的方法
  export const getItem = (key) => {
    try {
      return JSON.parse(localStorage.getItem(key))
    } catch (error) {
      return localStorage.getItem(key)
    }
  }
  
  // 删除的方法
  export const removeItem = key => {
    localStorage.removeItem(key)
  }
  